import { BaseChartConfig } from './basechartconfig.js';
import { TemplateManager } from '/src/util/templatemanager/templatemanager.js'

export class ChartConfig extends BaseChartConfig {
    constructor(container, options) {
        super(container, options);
    }

    async generateConfigForm() {
        await this.generateBaseConfigForm();
        await this.generateSeriesConfigForm();
    }

    async generateSeriesConfigForm() {
        this.$seriesConfigContainer.empty();

        for (const [index, series] of this.data.series.entries()) {
            try {
                const html = await TemplateManager.loadTemplate('/src/components/component/chart/sequence/chart-series-config.html', {
                    index: index,
                    name: series.name,
                    cid: this.cid
                });
                this.$seriesConfigContainer.append(html);
                this.generateSeriesNameConfigForm(index, series);
                this.generateSeriesTypeConfigForm(index, series);
            } catch (error) {
                console.error(`加载第 ${index} 个系列配置模板失败`, error);
            }
        }
    }
}